<?php 
    require_once("./system/loginCheck.php");
    require_once("../congfig/config.php");

    $realname=$_POST["tName"];
    $age=$_POST["tAge"];
    $phone=$_POST["tPhone"];
    $uid=$_POST["uid"];

    // echo $realname."<br>".$age."<br>".$phone."<br>".$uid;
    $sql="select * from userinfor where uid = $uid";
    $result=$conn->query($sql);
    $row=$result->fetch_array();
    if($row!=false){
    	$sql1="update `userinfor` set `realname`='$realname',`age`=$age,`phone`=$phone WHERE uid = $uid";
    	$result1=$conn->query($sql1);
    	if($result1){
    		$text="修改成功";
    		header("location:tOwner.php?text=$text");
    	}
    	else{
    		echo "失败，3秒返回";
    		header("refresh:3;url='tOwner.php'");
    	}
    
    }
    else {
    	$sql2="insert into`userinfor`(`id`, `uid`, `realname`, `age`, `phone`) values (null,$uid,'$realname',$age,$phone)";
    	$result2=$conn->query($sql2);
    	if($result2){
    		$text="修改成功";
    		header("location:tOwner.php?text=$text");
    	}
    	else{
    		echo "失败，3秒返回";
    		header("refresh:3;url='tOwner.php'");
    	}
    }
    

 ?>